﻿namespace EyeOpen.BomberMan
{
	using System.Linq;

	public class MapValidator
	{
		public void Validate(Map map)
		{
			CheckPlayer(map);
		}

		/// <exception cref="TooMuchPlayersException"></exception>
		/// <exception cref="PlayerNotFoundException"><c>PlayerNotFoundException</c>.</exception>
		private void CheckPlayer(Map map)
		{
			var playerFound = map.Count(c => c == ItemType.Player);

			if (playerFound == 0)
			{
				throw new PlayerNotFoundException();
			}

			if (playerFound > 1)
			{
				throw new TooMuchPlayersException();
			}
		}
	}
}